package com.nulldev.util.security.encryptAPI_rw.api;

import com.nulldev.util.data.Variables;
import com.nulldev.util.data.Charsets.CharsetUtil;

public interface IStandardBlockingCipher extends IBlockingCipher {

	@Override
	default ICipherType getCipherType() {
		return ICipherType.PRIVATE_KEY;
	}

	public byte[] encrypt(final byte[] data, final byte[] key);

	public default byte[] encrypt(final String data, final byte[] key) {
		return encrypt(Variables.requireNonNullObject(data, "data").getBytes(CharsetUtil.UTF_8), key);
	}

	public default byte[] encrypt(final byte[] data, final String key) {
		return encrypt(data, Variables.requireNonNullObject(key, "key").getBytes(CharsetUtil.UTF_8));
	}

	public default byte[] encrypt(final String data, final String key) {
		return encrypt(Variables.requireNonNullObject(data, "data").getBytes(CharsetUtil.UTF_8),
				Variables.requireNonNullObject(key, "key").getBytes(CharsetUtil.UTF_8));
	}

	public byte[] decrypt(final byte[] data, final byte[] key);

	public default byte[] decrypt(final String data, final byte[] key) {
		return decrypt(Variables.requireNonNullObject(data, "data").getBytes(CharsetUtil.UTF_8), key);
	}

	public default byte[] decrypt(final byte[] data, final String key) {
		return decrypt(data, Variables.requireNonNullObject(key, "key").getBytes(CharsetUtil.UTF_8));
	}

	public default byte[] decrypt(final String data, final String key) {
		return decrypt(Variables.requireNonNullObject(data, "data").getBytes(CharsetUtil.UTF_8),
				Variables.requireNonNullObject(key, "key").getBytes(CharsetUtil.UTF_8));
	}

}
